import { RouteRecordRaw, createRouter, createWebHistory } from 'vue-router'
import Dashboard from '@/views/Monitor/Dashboard.vue'
import PollutionSource from '@/views/Monitor/PollutionSource.vue'
import TracingIndex from '@/views/Tracing/Index.vue'
import EvaluationIndex from '@/views/Evaluation/Index.vue'
import EnterpriseProfile from '@/views/EnterpriseProfile/Index.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'login',
    component: () => import('@/views/Login/Index.vue')
  },

  {
    path: '/sewagePlant',
    name: 'sewagePlant',
    redirect: '/sewagePlant/main',
    component: () => import('@/views/CommonNavbar/Index.vue'),
    children: [
      {
        path: 'main',
        name: 'main',
        component: () => import('@/views/Main/Index.vue'),
      },
      {
        path: 'monitor',
        name: 'monitor',
        component: () => import('@/views/CommonContent/Index.vue'),
        meta: {
          title: '环境监测仪表盘'
        },
        children: [
          {
            path: 'dashboard',
            name: 'monitor-dashboard',
            component: Dashboard,
            meta: {
              title: '环境监测仪表盘'
            }
          },
          {
            path: 'pollution-source',
            name: 'pollution-source',
            component: PollutionSource,
            meta: {
              title: '环境污染源监测'
            }
          }
        ]
      },
      {
        path: 'assay',
        name: 'assay',
        component: () => import('@/views/Assay/Index.vue'),
        children: []
      },
      {
        path: 'stock',
        name: 'stock',
        component: () => import('@/views/Stock/Index.vue'),
        children: []
      },
      {
        path: 'system',
        name: 'system',
        component: () => import('@/views/System/Index.vue'),
        children: []
      },
      {
        path: 'manageCockpit',
        name: 'manageCockpit',
        component: () => import('@/views/ManageCockpit/Index.vue')
      },
      {
        path: 'operations',
        name: 'operations',
        component: () => import('@/views/Operations/Index.vue')
      },
      {
        path: 'equipment',
        name: 'equipment',
        component: () => import('@/views/Equipment/Index.vue'),
        children: []
      },
      {
        path: 'matter',
        name: 'matter',
        component: () => import('@/views/Matter/Index.vue')
      },
      {
        path: 'reports',
        name: 'reports',
        component: () => import('@/views/Reports/Index.vue'),
        children: []
      },
      {
        path: 'diagnosis',
        name: 'diagnosis',
        component: () => import('@/views/Diagnosis/Index.vue'),
        children: []
      },
      {
        path: 'collectionConfig',
        name: 'collectionConfig',
        component: () => import('@/views/CollectionConfig/Index.vue'),
        children: []
      }
    ]
  },
  {
    path: '/monitor',
    name: 'standalone-dashboard',
    component: Dashboard,
    props: (route) => ({ key: Date.now() })
  },
  {
    path: '/pollution-source',
    name: 'standalone-pollution-source',
    component: PollutionSource,
    props: (route) => ({ key: Date.now() })
  },
  {
    path: '/pollution-tracing',
    name: 'standalone-pollution-tracing',
    component: TracingIndex,
    props: (route) => ({ key: Date.now() })
  },
  {
    path: '/environment-evaluation',
    name: 'environment-evaluation',
    component: EvaluationIndex,
    props: (route) => ({ key: Date.now() })
  },
  {
    path: '/enterprise-profile',
    name: 'enterprise-profile',
    component: EnterpriseProfile
  }
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

export default router
